﻿using System;
using OnlineGameClient.ViewModel;
using System.Windows.Controls;
using System.Collections.Generic;
using System.Windows;

namespace OnlineGameClient.View
{
    public partial class MainView : UserControl
    {
        Dictionary<string, object> _view;
        public MainView()
        {
            InitializeComponent();

            _view = new Dictionary<string, object>();
            _view.Add("GameRoomsView", new GameRoomsView());
            _view.Add("GameRoomDetailView", new GameRoomDetailView());
            _view.Add("GameView", new GameView());

            this.DataContext = new GameRoomViewModel(this.Dispatcher,
                new Service.GameServiceClientProxy());

            Loaded += new RoutedEventHandler(MainView_Loaded);
           
        }

        void MainView_Loaded(object sender, RoutedEventArgs e)
        {
            var loginw = new LoginWindow();
            loginw.DataContext = this.DataContext;

            loginw.Show();
        }

        public FrameworkElement SwithView(string viewname)
        {
            tcc1.Content = _view[viewname];
            return tcc1.Content as FrameworkElement;
        }

    }
}